<script setup>
import GoodsItem from "@/views/Home/components/GoodsItem.vue"
import {computed, ref} from "vue";
import {useRoute} from "vue-router";
import {getHotGoodsAPI} from "@/apis/detail.js";
const props = defineProps({
  hotType: {
    type: Number
  }
})
const goodList = ref([])
const route = useRoute()
const getHotList = async () => {
  const { result:res } = await getHotGoodsAPI({
    id: route.params.id,
    type: props.hotType
  })
  console.log(res)
  goodList.value = res
}
getHotList()

const titleType = {
  1:'周热榜',
  2:'24小时热榜'
}

const title = computed( () => titleType[props.hotType])
</script>

<template>
  <div class="goods-hot">
    <h3>{{ title }}</h3>
    <GoodsItem v-for="goods in goodList" :goods="goods"></GoodsItem>
  </div>
</template>

<style scoped lang="scss">
.goods-hot {
  h3 {
    height: 70px;
    background-color: $helpColor;
    color: #fff;
    font-size: 18px;
    line-height: 70px;
    padding-left: 25px;
    margin-bottom: 10px;
    font-weight: normal;
  }
  .goods-item{
    background-color: #fff;
    width: auto;
    margin-bottom: 10px;
  }
}
</style>